<template>

    <el-container v-show="!dialog.save">
        <el-header class="elheader">

            <div class="left-panel">
                <div class="name">中波中心调度令</div>
                <div class="fieldname">时间</div>
                <div>
                    <el-date-picker v-model="time" type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
                </div>
                <div class="fieldname">关键词</div>
                <el-input v-model="list.params.keyword" style="width:200px;" clearable />
                <div style="padding-left:10px"></div>
                <el-button type="primary" size="default" @click="upsearch">查询</el-button>
                <!-- <el-button type="primary" v-auth="'order.new'" size="default" icon="el-icon-plus" @click="orderAdd">新增</el-button> -->
            </div>

        </el-header>
        <el-main class="nopadding">
            <scTable ref="table" :apiObj="list.apiObj" row-key="ProjectID" :params="list.params" stripe :header-cell-class-name="getheadcellclass" :cell-class-name="getcellclass">
                <!-- <el-table-column type="selection" width="50"></el-table-column> -->
                <el-table-column type="expand">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">
                            <el-table :show-header="false" :data="scope.row.children" :cell-class-name="getcellclassdetail" :row-class-name="tableRowClassName" :border="false">
                                <el-table-column width="8" />
                                <el-table-column type="index" width="40" :index="indexMethod" />
                                <el-table-column label="调度令文号" prop="ProjectSerrial" width="180">
                                    <template #default="detail">
                                        <div>{{scope.row.ProjectSerrial}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="台站" prop="stationName" width="140">
                                    <template #default="detail">
                                        <div>{{detail.row.stationName}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="起草人" prop="ProjectSenderName" width="120">
                                    <template #default="detail">
                                        <div>{{scope.row.ProjectSenderName}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="起草时间" prop="CreateTime" width="180">
                                    <template #default="detail">
                                        <div>{{scope.row.CreateTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="审核人" prop="AuditorName" width="120">
                                    <template #default="detail">
                                        <div v-if="scope.row.currentVeriyuserName==''||scope.row.currentVeriyuserName==null">
                                            <el-icon :size="svgSize">
                                                <component :is="scIcons.Gou" />
                                            </el-icon>
                                        </div>
                                        <div v-else class="tablecell" @click="table_show(scope.row)">
                                            <el-icon :size="svgSize">
                                                <component class="hover" :is="scIcons.Gantanhao" />
                                            </el-icon>
                                            {{scope.row.currentVeriyuserName}}
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="下发" prop="xfTime" width="60">
                                    <template #default="detail">
                                        <div v-if="scope.row.xfTime==''||scope.row.xfTime==null"></div>
                                        <div v-else>已下发</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="下发时间" prop="xfTime" width="160">
                                    <template #default="detail">
                                        <div>{{scope.row.xfTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column width="20">

                                </el-table-column>
                                <el-table-column label="接收人" prop="acceptUserName" width="140">
                                    <template #default="detail">
                                        <div v-if="scope.row.WorkflowID>=3">
                                            <div class="tablecell  " @click="detailNotice(detail.row,scope.row.ProjectSerrial,'接收',scope.row.ProjectID)" v-if="detail.row.acceptUser==''">
                                                <el-icon :size="svgSize">
                                                    <component class="hover" :is="scIcons.Laba" />
                                                </el-icon>
                                            </div>
                                            <div v-else class="tablecell">
                                                <el-icon :size="svgSize">
                                                    <component :is="scIcons.Gou" />
                                                </el-icon>
                                                {{detail.row.acceptUserName}}
                                            </div>
                                        </div>

                                    </template>
                                </el-table-column>
                                <el-table-column label="接收时间" prop="acceptTime" width="180">
                                    <template #default="detail">
                                        <div>{{detail.row.acceptTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="设置运行" prop="executeUser" width="110">
                                    <template #default="detail">
                                        <div v-if="detail.row.acceptUser!=''">
                                            <div class="tablecell  " @click="detailNotice(detail.row,scope.row.ProjectSerrial,'执行',scope.row.ProjectID)" v-if="detail.row.executeUser=='' ">
                                                <el-icon :size="svgSize">
                                                    <component class="hover" :is="scIcons.Laba" />
                                                </el-icon>未设置
                                            </div>
                                            <div v-else class="tablecell">
                                                <el-icon :size="svgSize">
                                                    <component :is="scIcons.Gou" />
                                                </el-icon>
                                                {{detail.row.executeUser==''?'':'发送成功'}}
                                            </div>
                                        </div>
                                        <!-- <div>{{detail.row.executeUser==''?'':'发送成功'}}</div> -->
                                    </template>
                                </el-table-column>
                                <el-table-column label="设置时间" prop="executeTime" width="180">
                                    <template #default="detail">

                                        <div>{{detail.row.executeTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="校验" prop="check" width="80">
                                    <template #default="detail">

                                        <div>{{detail.row.check}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="执行情况" prop="execution" width="80">
                                    <template #default="detail">

                                        <div class="tablecell" v-if="detail.row.execution==100">
                                            <el-icon :size="svgSize">
                                                <component :is="scIcons.Gou" />
                                            </el-icon>
                                            {{detail.row.execution+'%'}}
                                        </div>
                                        <div v-else class="tablecell">
                                            <el-icon :size="svgSize">
                                                <component :is="scIcons.Shuaxin" />
                                            </el-icon>
                                            {{detail.row.execution+'%'}}
                                        </div>

                                        <!-- <div>{{detail.row.execution+'%'}}</div> -->
                                    </template>
                                </el-table-column>
                                <el-table-column label="告警次数" prop="alarmTime" width="120">
                                    <template #default="detail">
                                        <div v-if="detail.row.alarmTime>0" class="tablecell  " @click="showAlarm(detail.row.alarmdata)">
                                            <el-icon :size="svgSize">
                                                <component class="hover" :is="scIcons.Alarm" />
                                            </el-icon>
                                            {{detail.row.alarmTime}}(点击查看)
                                        </div>
                                        <div v-else>0</div>

                                    </template>
                                </el-table-column>
                                <el-table-column label="紧急联系人" prop="emergencyNum">
                                    <template #default="detail">

                                        <div class="tablecell  " @click="showEmergencyNum(detail.row.stationID)">
                                            <el-icon :size="svgSize">
                                                <component class="telhover" :is="scIcons.Tel" />
                                            </el-icon>
                                        </div>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </template>
                </el-table-column>

                <el-table-column label="调度令文号" prop="ProjectSerrial" width="180"></el-table-column>
                <el-table-column label="台站" prop="stationIds" width="140">
                    <template #default="scope">
                        <div v-if="scope.row.stationIds.split(',').length>1">多台站</div>
                        <div v-else>{{scope.row.stationName}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="起草人" prop="ProjectSenderName" width="120"></el-table-column>
                <el-table-column label="起草时间" prop="CreateTime" width="180"></el-table-column>
                <el-table-column label="审核人" prop="AuditorName" width="120">

                    <template #default="scope">
                        <div class="tablecell" v-if="scope.row.currentVeriyuserName==''||scope.row.currentVeriyuserName==null">
                            <el-icon :size="svgSize">
                                <component :is="scIcons.Gou" />
                            </el-icon>
                        </div>
                        <div v-else class="tablecell" @click="table_show(scope.row)">
                            <el-icon :size="svgSize">
                                <component class="hover" :is="scIcons.Gantanhao" />
                            </el-icon>
                            {{scope.row.currentVeriyuserName}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="下发" prop="xfTime" width="60">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>
                            <div v-if="scope.row.xfTime==''||scope.row.xfTime==null"></div>
                            <div v-else>已下发</div>
                        </div>

                    </template>
                </el-table-column>
                <el-table-column label="下发时间" prop="xfTime" width="160"></el-table-column>
                <el-table-column prop="fgx" width="20">

                </el-table-column>
                <el-table-column label="接收人" prop="acceptUser" width="120">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>
                            <div v-if="scope.row.WorkflowID>=3">
                                <div class="tablecell  " @click="Notice(scope.row,'接收')" v-if="scope.row.acceptUser=='' ">
                                    <el-icon :size="svgSize">
                                        <component class="hover" :is="scIcons.Laba" />
                                    </el-icon>
                                </div>
                                <div v-else class="tablecell">
                                    <el-icon :size="svgSize">
                                        <component :is="scIcons.Gou" />
                                    </el-icon>
                                    {{scope.row.acceptUserName}}
                                </div>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="接收时间" prop="acceptTime" width="180">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>{{scope.row.acceptTime}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="设置运行" prop="executeUser" width="110">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>

                        <div v-else>
                            <div v-if="scope.row.acceptUser!=''">
                                <div class="tablecell  " @click="Notice(scope.row,'执行')" v-if="scope.row.executeUser=='' ">
                                    <el-icon :size="svgSize">
                                        <component class="hover" :is="scIcons.Laba" />
                                    </el-icon>未设置
                                </div>
                                <div v-else class="tablecell">
                                    <el-icon :size="svgSize">
                                        <component :is="scIcons.Gou" />
                                    </el-icon>
                                    {{scope.row.executeUser==''?'':'发送成功'}}
                                </div>
                            </div>
                        </div>

                        <div v-else>{{scope.row.executeUser==''?'':'发送成功'}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="设置时间" prop="executeTime" width="180">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>{{scope.row.executeTime}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="校验" prop="check" width="80">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>{{scope.row.check}}</div>
                    </template>
                </el-table-column>
                <el-table-column label="执行情况" prop="execution" width="80">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>
                            <div class="tablecell" v-if="scope.row.execution==100">
                                <el-icon :size="svgSize">
                                    <component :is="scIcons.Gou" />
                                </el-icon>
                                {{scope.row.execution+'%'}}
                            </div>
                            <div v-else class="tablecell">
                                <el-icon :size="svgSize">
                                    <component :is="scIcons.Shuaxin" />
                                </el-icon>
                                {{scope.row.execution+'%'}}
                            </div>

                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="告警次数" prop="alarmTime" width="120">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">..........</div>
                        <div v-else>
                            <div class="tablecell  " v-if="scope.row.alarmTime>0" @click="showAlarm(scope.row.alarmdata)">
                                <el-icon :size="svgSize">
                                    <component class="hover" :is="scIcons.Alarm" />
                                </el-icon>
                                {{scope.row.alarmTime}}(点击查看)
                            </div>
                            <div v-else>0</div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="紧急联系人" prop="emergencyNum" width="90">
                    <template #default="scope">
                        <div v-if="scope.row.children.length>1">

                        </div>
                        <div v-else class="tablecell " @click="showEmergencyNum(scope.row.stationIds)">
                            <el-icon :size="svgSize">
                                <component class="telhover" :is="scIcons.Tel" />
                            </el-icon>
                            <!-- {{scope.row.emergencyNum}} -->
                        </div>
                    </template>
                </el-table-column>

                <!-- <el-table-column label="操作" align="left" width="580">
                    <template #default="scope">

                        <el-popconfirm title="确定删除吗？" @confirm="deteleRow(scope.row.ProjectID)">
                            <template #reference>
                                <el-button v-auth="'order.delete'" plain type="danger" size="small">删除</el-button>
                            </template>
                        </el-popconfirm>
                    </template>
                </el-table-column> -->
            </scTable>
        </el-main>
        <el-footer style="height:200px;">
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Gantanhao" />
                </el-icon>
                未审核提示,点击可进入审核流程,查看调度令
            </div>
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Laba" />
                </el-icon>
                流程未进行或进行错误预警，点击可自动发送消息提醒台站
            </div>
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Gou" />
                </el-icon>
                正常执行完毕流程
            </div>
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Tel" />
                </el-icon>
                点击可以看到台站所有联系方式
            </div>
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Shuaxin" />
                </el-icon>
                运行图执行中未完成
            </div>
            <div class="footrow">
                <el-icon :size="svgSize">
                    <component :is="scIcons.Alarm" />
                </el-icon>
                实时数据或执行结果报警
            </div>
            <div class="footrow">
                .......... 无意义不需要填写的数据
            </div>

        </el-footer>
    </el-container>
    <el-container v-if="dialog.save">
        <orderadd ref="saveDialog" @endSave="endSave" @verifyClick="verifyClick" @msgClick="msgClick" @executeClick="executeClick" @stopClick="stopClick" @submitClick="submitClick"></orderadd>
    </el-container>

    <el-dialog v-model="dialog.msg" width="30%" title='发送消息' :close-on-click-modal="false">

        <el-form :model="msgData" ref="msgForm" label-width="80px" :rules="msgRules" label-position="left" status-icon>
            <el-form-item label="接收方" prop="re_user">
                <el-select v-model="msgData.re_user" class="m-2" placeholder="">
                    <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
            </el-form-item>

            <el-form-item label="内容" prop="content">
                <el-input v-model="msgData.content" :rows="2" type="textarea" placeholder="" />
            </el-form-item>
        </el-form>

        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialog.msg = false">取消</el-button>
                <el-button type="primary" @click="sendMsg">确认</el-button>
            </span>
        </template>
    </el-dialog>

    <el-dialog v-model="dialog.verify" width="30%" title='审核' :close-on-click-modal="false">

        <el-form :model="verifyData" label-width="80px" label-position="left" status-icon>
            <el-form-item label="是否同意">
                <el-select v-model="verifyData.verifyvalue" class="m-2" placeholder="">
                    <el-option v-for="item in verifyoption" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
            </el-form-item>

            <el-form-item label="审核意见">
                <el-input v-model="verifyData.verifycontent" :rows="2" type="textarea" placeholder="" />
            </el-form-item>
        </el-form>

        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialog = verify">取消</el-button>
                <el-button type="primary" @click="confirmVerify">确认</el-button>
            </span>
        </template>
    </el-dialog>

    <el-drawer v-model="dialog.info" title="紧急联系人" custom-class="drawerBG" direction="rtl" destroy-on-close>
        <el-card shadow="never">
            <el-descriptions title="" :column="2" border>
                <div v-for="user,index in emergeUsers" :key="index">
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                <el-icon>
                                    <user />
                                </el-icon>
                                姓名
                            </div>
                        </template>
                        {{user.name}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                <el-icon>
                                    <iphone />
                                </el-icon>
                                手机
                            </div>
                        </template>
                        <el-tag>{{user.phone}}</el-tag>
                    </el-descriptions-item>
                </div>
            </el-descriptions>
        </el-card>
    </el-drawer>

    <el-drawer v-model="dialog.alarm" title="告警信息" custom-class="drawerBG" direction="rtl" destroy-on-close>
        <el-card shadow="never">
            <el-descriptions style="margin-bottom:10px;" v-for="alarm,index in alarmData" :key="index" title="" :column="2" border>
                <div>
                    <!-- <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                告警名
                            </div>
                        </template>
                        {{alarm.AlarmName}}
                    </el-descriptions-item> -->
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                类型
                            </div>
                        </template>
                        <el-tag>{{alarm.AlertType}}</el-tag>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                告警时间
                            </div>
                        </template>
                        {{alarm.StartTime}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                发射机
                            </div>
                        </template>
                        <el-tag>{{alarm.TransmitterNumber}}</el-tag>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                天线
                            </div>
                        </template>
                        <el-tag>{{alarm.AnntenaNumber}}</el-tag>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                频率
                            </div>
                        </template>
                        <el-tag>{{alarm.Frequency}}</el-tag>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                功率
                            </div>
                        </template>
                        <el-tag>{{alarm.Capacity}}</el-tag>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template #label>
                            <div class="cell-item">
                                告警内容
                            </div>
                        </template>
                        {{alarm.AlertContent}}
                    </el-descriptions-item>
                </div>
            </el-descriptions>

        </el-card>
    </el-drawer>
</template>

<script setup>  
import orderadd from './check'
import { reactive, getCurrentInstance, onMounted, ref, nextTick } from 'vue'
import * as scIcons from '@/assets/icons'

const { proxy } = getCurrentInstance()

//#region 变量定义

//审核选项 
let verifyData = reactive({
    verifyvalue: '1',
    verifycontent: ''
})
let verifyoption = ref([
    {
        value: '1',
        label: '同意',
    },
    {
        value: '0',
        label: '不同意',
    }
])

//发送消息 
let msgData = reactive({
    re_user: '',
    content: ''
})
let msgForm = ref(null)
let msgRules = reactive({
    re_user: [
        { required: true, message: '请选择接收人', trigger: 'blur' }
    ],
    content: [
        { required: true, message: '请填写内容', trigger: 'blur' }
    ],
})


//弹框控制
let dialog = ref({
    save: false,
    info: false,
    verify: false,
    msg: false,
    alarm: false
})

let currenttime = new Date(new Date().setDate(new Date().getDate() + 30))
let lasttime = new Date(new Date() - 1000 * 60 * 60 * 24 * 30)

//新增编辑弹窗对象
let saveDialog = ref(null)

//时间
let time = ref(['', ''
    // new Date(lasttime.getFullYear(), lasttime.getMonth(), lasttime.getDate(), lasttime.getHours(), 0, 0),
    // new Date(currenttime.getFullYear(), currenttime.getMonth(), currenttime.getDate(), currenttime.getHours(), 0, 0)
])

//列表查询接口和参数
let list = ref({
    apiObj: proxy.$API.order.list,
    //搜索参数
    params: {
        keyword: '',
        starttime: time.value[0] == '' ? '' : proxy.$TOOL.dateFormat(time.value[0], 'yyyy-MM-dd hh:mm:ss'),
        endtime: time.value[1] == '' ? '' : proxy.$TOOL.dateFormat(time.value[1], 'yyyy-MM-dd hh:mm:ss'),
        status: isNaN(proxy.$route.path.split('/')[proxy.$route.path.split('/').length - 1]) ? -1 : { type: proxy.$route.path.split('/')[proxy.$route.path.split('/').length - 1] }, //状态1-6   -1表示全部
        deptTtype: proxy.$TOOL.data.get("USER_INFO").deptTtype,//部门ID
        deptId: proxy.$TOOL.data.get("USER_INFO").deptId,//部门ID
        userId: proxy.$TOOL.data.get("USER_INFO").userId,//用户ID
    }
})
//列表对象
let table = ref(null)
//列表选中行
let selectRow = ref({})
//用户列表
let userList = reactive([])
//紧急联系人
let emergeUsers = reactive([])
//svg图大小
let svgSize = ref(20)
//告警信息
let alarmData = reactive([])
//#endregion


//#region method

//显示告警信息
let showAlarm = (alarmdata) => {
    alarmData.length = 0
    alarmData.push(...alarmdata)

    dialog.value.alarm = true
}

//显示紧急联系人
let showEmergencyNum = async (stationID) => {

    let result = await proxy.$API.order.contactor.get({ stationID: stationID })
    if (result.code == 200) {

        emergeUsers.length = 0
        emergeUsers.push(...result.data)

        dialog.value.info = true
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })
}

//下拉台站通知
let detailNotice = async (row, ProjectSerrial, msg, ProjectID) => {

    let newdata = {
        type: 'user',
        sender: proxy.$TOOL.data.get("USER_INFO").userId,
        re_dept: row.stationID,
        content: '催办【' + ProjectSerrial + '】调度令 ' + msg,
        ProjectID: ProjectID
    }

    let result = await proxy.$API.system.message.sendMsgToDept.post(newdata)

    if (result.code == 200) {
        proxy.$message.success("发送成功")
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })
}
//主表台站通知
let Notice = async (row, msg) => {

    let newdata = {
        type: 'user',
        sender: proxy.$TOOL.data.get("USER_INFO").userId,
        re_dept: row.stationIds,
        content: '催办【' + row.ProjectSerrial + '】调度令 ' + msg,
        ProjectID: row.ProjectID
    }

    let result = await proxy.$API.system.message.sendMsgToDept.post(newdata)

    if (result.code == 200) {
        proxy.$message.success("发送成功")
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })
}

//查看
let table_show = (row) => {
    selectRow.value = row
    let _obj = JSON.stringify(selectRow.value)
    let newdata = JSON.parse(_obj)
    dialog.value.save = true
    newdata.readonly = true
    newdata.verifyonly = true
    nextTick(() => {
        saveDialog.value.setValue(newdata)
    })
}


//窗口新增
let orderAdd = () => {
    dialog.value.save = true
    nextTick(() => {
        saveDialog.value.setValue({ ProjectID: -1 })
        saveDialog.value.pageRset()
    })
}

//保存成功
let endSave = () => {
    dialog.value.save = false

    table.value.refresh()
}

//提交审核
let table_submit = async (row) => {

    let result = await proxy.$API.order.submit.post(
        {
            ProjectID: row.ProjectID,
            sender: proxy.$TOOL.data.get("USER_INFO").userId
        }
    )

    if (result.code == 200) {
        proxy.$message.success("提交成功")
        dialog.value.verify = false
        upsearch()
        if (saveDialog) {
            dialog.value.save = false
        }
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })
}
let submitClick = async () => {
    await table_submit(selectRow.value)
}

//审核按钮
let verify = (row) => {
    if (proxy.$TOOL.data.get("USER_INFO").userId == row.ProjectAuditor || proxy.$TOOL.data.get("USER_INFO").userId == row.ProjectAuditor2) {
        selectRow.value = row
        dialog.value.verify = true
        nextTick(() => {
        })
    }
    else
        proxy.$alert('您不是指定的审核人!', "异常", { type: 'error' })
}
let verifyClick = () => {

    if (proxy.$TOOL.data.get("USER_INFO").userId == selectRow.value.ProjectAuditor || proxy.$TOOL.data.get("USER_INFO").userId == selectRow.value.ProjectAuditor2) {

        dialog.value.verify = true
        nextTick(() => {

        })
    }
    else
        proxy.$alert('您不是指定的审核人!', "异常", { type: 'error' })
}
//审核确认
let confirmVerify = async () => {
    let content = verifyData.verifyvalue == '1' ? '同意' : '不同意'
    let result = await proxy.$API.order.verify.post(
        {
            ProjectID: selectRow.value.ProjectID,
            sender: proxy.$TOOL.data.get("USER_INFO").userId,
            content: content + '!   ' + verifyData.verifycontent,
            ifthroug: verifyData.verifyvalue,
            stationIds: selectRow.value.stationIds
        }
    )

    if (result.code == 200) {
        proxy.$message.success("审核成功")
        dialog.value.verify = false
        upsearch()
        if (saveDialog) {
            // saveDialog.value.getFlow()
            dialog.value.save = false
        }
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })

}

//催办发送消息
let sendMsg = async () => {

    msgForm.value.validate(async (valid) => {
        if (valid) {
            let _obj = JSON.stringify(msgData)
            let newdata = JSON.parse(_obj)
            newdata.type = 'user'
            newdata.sender = proxy.$TOOL.data.get("USER_INFO").userId
            let result = await proxy.$API.system.message.sendMsg.post(newdata)

            if (result.code == 200) {
                proxy.$message.success("发送成功")
                dialog.value.msg = false
            }
            else
                proxy.$alert(result.message, "异常", { type: 'error' })
        } else {
            proxy.$alert("请正确填写！", "提示", { type: 'error' })
            return false;
        }
    })

}
let msgClick = () => {
    dialog.value.msg = true
}


//执行
let execute = async (row, childrenrow) => {

    let result = await proxy.$API.order.execute.post(
        {
            ProjectID: row.ProjectID,
            sender: proxy.$TOOL.data.get("USER_INFO").userId,
            stationID: childrenrow.stationID,
            content: '',
            extime: proxy.$TOOL.dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss')
        }
    )
    if (result.code == 200) {
        proxy.$message.success("操作成功")

        upsearch()
        if (saveDialog) {
            dialog.value.save = false
        }
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })

}
let executeClick = async () => {
    await execute(selectRow.value)
}

//中止
let stop = async (row) => {

    let result = await proxy.$API.order.stop.post(
        {
            ProjectID: row.ProjectID,
            sender: proxy.$TOOL.data.get("USER_INFO").userId,
            content: ''
        }
    )
    if (result.code == 200) {
        proxy.$message.success("操作成功")

        upsearch()
        if (saveDialog) {
            dialog.value.save = false
        }
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })

}

//删除
let deteleRow = async (id) => {

    let result = await proxy.$API.order.delete.post({ id: id })
    if (result.code == 200) {
        proxy.$message.success("删除成功")

        table.value.refresh()
    }
    else
        proxy.$alert(result.message, "异常", { type: 'error' })
}

//索引函数
let indexMethod = (index) => {
    return (index + 1) + ' )'
}

//列表自定义斑马纹
let tableRowClassName = (row) => {
    return 'warning-row'
    // if (row.rowIndex % 2 == 0) {
    //     return 'warning-row'
    // } else {
    //     return ''
    // }
}
let getcellclass = (row) => {

    if (row.columnIndex == 8)
        return 'cellborder'
}
let getcellclassdetail = (row) => {

    if (row.columnIndex == 9)
        return 'cellborder'
}
let getheadcellclass = (row) => {

    if (row.columnIndex == 8)
        return 'cellborder'
    if (row.columnIndex == 9)
        return 'fontred'
    if (row.columnIndex == 10 || row.columnIndex == 11)
        return 'fontred'
    if (row.columnIndex == 12)
        return 'fontred'
    if (row.columnIndex == 1 || row.columnIndex == 13 || row.columnIndex == 14 || row.columnIndex == 15 || row.columnIndex == 16)
        return 'fontblue'
}

//列表查询函数
let upsearch = () => {
    list.value.params.starttime = time.value[0] == '' ? '' : proxy.$TOOL.dateFormat(time.value[0], 'yyyy-MM-dd hh:mm:ss')
    list.value.params.endtime = time.value[1] == '' ? '' : proxy.$TOOL.dateFormat(time.value[1], 'yyyy-MM-dd hh:mm:ss')

    table.value.upData(list.value.params)
}

//初始化
onMounted(async () => {
    //console.log(scIcons.Tel);
    let user = await proxy.$API.system.user.all.get()
    userList.push(...user.data)
})

//#endregion
</script>

<style lang="scss"  scoped>
.footrow {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    i {
        margin-right: 10px;
    }
}
.tablecell {
    display: flex;
    i {
        margin-right: 5px;
    }
}
.hover:hover {
    cursor: pointer;
    box-shadow: 0px 0px 6px 1px rgb(221, 101, 114);
    border-radius: 120px 120px 120px 120px;
}
.telhover:hover {
    cursor: pointer;
    box-shadow: 0px 0px 6px 1px rgb(0, 229, 96);
    border-radius: 120px 120px 120px 120px;
}
.el-table .warning-row {
    background-color: var(--el-color-warning-light-9);
}
.fontred {
    color: rgb(240, 100, 100);
}
.fontblue {
    color: rgb(62, 62, 215);
}
.cellborder {
    border-left-color: rgb(238, 15, 15);
    border-left-style: dotted;
    border-left-width: 1px;
}
.elheader {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: 60px !important;
    .left-panel {
        width: 100%;
    }

    .name {
        margin-left: 10px;
    }
    .fieldname {
        margin-left: 40px;
        margin-right: 10px;
    }
}
</style>